import axios from 'axios'
import Element from 'element-ui'
//前缀
axios.defaults.baseURL="http://localhost:8089"

//前置拦截
axios.interceptors.request.use(config => {
    return config
})

//后置拦截
axios.interceptors.response.use(response => {
    const res = response.data


    //正常返回不拦截
    if (res.code === 200){
        return response
    }
    //异常
    Element.Message({
        showClose: true,
        message: '错了哦，'+res.msg,
        type: 'error'
    });


    return Promise.reject(response.data)
},error => {
    //后端返回前端异常进入这里
    }
)
